<template>
  <div class="box">
    helloworld
  </div>
  <jsx ref="c-jsx"></jsx>
</template>
<script lang="jsx">
import {hex_md5} from '@/libs/md5.js';
import Qs from '@/libs/qs.js';
import moment from 'moment';
import jsx from './components/JsxComponent.vue'
import SingleSlot from './components/SingleSlot.vue'
export default {
  components : {
    jsx,
    SingleSlot
  },
  data() {
    return {
      jsxTemplate : <div>测试</div>,
      ja : 1,
      jb : 2
    };
  },
  methods: {
    /*o = ''.concat(l).concat(p)*/
    /*l = 'p'.concat(u).concat(g),*/
    /*p10120241011165212 933b0de439d2d7d6ec5e90af6b03ee4e*/
    /*'p' + u + g + p*/
    /*u = 101*/
    /*g = 20241011165212*/
    /*p = r.hex_md5(''.concat(d).concat(s)) */
    //f
    /*d = 参数排序 s为password*/

    encrypt(time) {
      /*let time = moment().format('YYYYMMDDHHmmss');*/
      let params = {
        appname: 'fangx',
        v: '1.3.4',
        miniplat: 'weixin',
        scene: '1036',
        keyword: '怡康花园',
        page: '1',
        inc_eagt: '1',
        listposition: 'all',
        city: '常州',
        orderby: '15',
        pagesize: '20',
        micalltime: time,
        miversion: 'p',
        misource: '101',
      };
      let headerSign = {
        encodeNumber: '101',
        password: '4f0c6725d917f8fe4e2791921187fd7d',
        miversgin: 'p',
      };

      let params_query = Qs.stringify(params, {
        encode: false,
        sort: (a, b) => {
          return a < b ? -1 : 1;
        },
      });
      params_query = params_query + headerSign.password;
      console.log(params_query);
      let sign = hex_md5(params_query);
      let usign = headerSign.miversgin + headerSign.encodeNumber + time + sign;
      return usign;
    },
    testMd5(){
      let url = `https://miniapp.fang.com/zf/searchList?appname=fangx&v=1.3.4&miniplat=weixin&scene=1036&keyword=%E6%80%A1%E5%BA%B7%E8%8A%B1%E5%9B%AD&page=1&inc_eagt=1&listposition=all&city=%E5%B8%B8%E5%B7%9E&orderby=15&pagesize=20`;
      //p10120241011165134 802a947516eb926c25a4d986205988cb

      let queryIndex = url.indexOf('?');
      let query = url.slice(queryIndex + 1);
      query = Qs.parse(query);
      let headerSign = {
        encodeNumber: '101',
        password: '4f0c6725d917f8fe4e2791921187fd7d',
        miversgin: 'p',
      };
      let g = '20241011165134';
      let i = headerSign;
      let u = i.encodeNumber;
      let params = Object.assign(
        query,
        {},
        {micalltime: g, miversion: i.miversgin, misource: u},
      );
      console.log(params);
      console.log(JSON.stringify(params));
      let params_query = Qs.stringify(params, {
        encode: false,
        sort: (a, b) => {
          return a < b ? -1 : 1;
        },
      });
      params_query = params_query + headerSign.password;
      let sign = hex_md5(params_query);

      let usign = headerSign.miversgin + headerSign.encodeNumber + g + sign;
      console.log(usign === 'p10120241011165134802a947516eb926c25a4d986205988cb');

      let num = this.encrypt('20241011165134');
      console.log(num);
      let flag = this.encrypt('20241011165134') === 'p10120241011165134802a947516eb926c25a4d986205988cb'
      console.log(flag);

      flag = this.encrypt('20241012102041') === 'p101202410121020411a8a6770eed6d06cb79ba93cc7dd5ba1'
      console.log(flag);
    }
  },
  mounted() {
    this.testMd5();
    console.log(this.$root);
    let c = this.$refs['c-jsx'];
    let ja = {
      a : 1,
      b : 2
    }

    const slots = {
      default(abc){
        return "helloworld" +  abc.a + ":" + abc.b;
      },
      header(){
        return <div>这里是头部</div>
      }
    }
    c.show({
      /*template : <div>测试123*/
        /*<single-slot v-slots={slots}></single-slot>*/
      /*</div>*/
      template : <div>测试123
        <single-slot>
      {{ 
        default(abc){
          return "helloworld" +  abc.a + ":" + abc.b;
        },
        header(){
          return <div>这里是头部</div>
        }
      }}
      </single-slot>
      </div>
    })
    /*this.$root.component('abc',{*/
      /*render(){*/
        /*return <div>helloworld</div>;*/
      /*}*/
    /*});*/
    /*this.dynamaicComponent = 'abc';*/
    /*console.log(div);*/
  },
};
</script>
<style type="text/css">
.box {
  width: 100px;
  height: 100px;
  border: 1px solid #000;
}
</style>
